package com.grape.dbmiddle.consumer.listener;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.grape.dbmiddle.consumer.mapper.TxMiddleMapper;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@RabbitListener(queues = "tx-quene-to")
public class FanoutListener {
	@Autowired
	TxMiddleMapper txMiddleMapper;
	@RabbitHandler
	public void process(String msg){
		System.out.println("consumer接受消息"+msg);
		JSONObject jsonObject = JSONUtil.parseObj(msg);
		String txid = jsonObject.getStr("txid");
		//修改消息状态已完成
		txMiddleMapper.update(txid,2);
	}
}